package com.zf.zffencheng.controller.sms;

import com.zf.zffencheng.model.Result;
import com.zf.zffencheng.service.SmsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: SmsController <br/>
 * Description:  <br/>
 * date: 2021/5/11 9:38<br/>
 *
 * @author william <br/>
 */
@Api(tags = "短消息服务")
@RestController
@RequestMapping("/sapi/sms")
public class SmsController {

    private final SmsService smsService;


    @Autowired
    public SmsController(SmsService smsService){
        this.smsService = smsService;
    }

    @PostMapping("send")
    @ApiOperation("短信发送")
    public Result send(@RequestParam("mobile") String mobile) throws Exception {
        String code = RandomStringUtils.random(6, false, true);
        return  smsService.send(mobile, code);
    }

}
